package com.t235.gc.biz.service;

import com.t235.gc.entity.SysManager;
import com.t235.gc.entity.Venues;
import com.t235.gc.managerVo.SysManagerVo;
import com.t235.gc.mapper.*;
import com.t235.gc.orderVo.PartnersInviteVo;
import com.t235.gc.orderVo.RecyclersVo;
import com.t235.gc.orderVo.UserCashAuditVo;
import com.t235.gc.shenhe.ManagerAndRecordVo;
import com.t235.gc.shenhe.PartnersAndRecordVo;
import com.t235.gc.userIntiverVo.UserInviterVo;
import com.t235.gc.venuesVo.VenuesVo;
import com.t235.gc.yunweiVo.FaultAndReplenishmentVo;
import com.t235.gc.yunweiVo.GoodsAndReplenishmentVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BizService {
    @Autowired
    private UserCashRecordMapper userCashRecordMapper;

    @Autowired
    private PartnersInviteMapper partnersInviteMapper;

    @Autowired
    private RecyclersMapper recyclersMapper;




    @Autowired
    private SysManagerMapper sysManagerMapper;
    @Autowired
    private PartnersMapper partnersMapper;
    @Autowired
    private ReplenishmentRecordMapper replenishmentRecordMapper;
    @Autowired
    private DeviceFaultRecordMapper deviceFaultRecordMapper;
    @Autowired
    private VenuesMapper venuesMapper;
    @Autowired
    private UserInviteMapper userInviteMapper;



    public List<UserCashAuditVo> userCashCheckQuery(UserCashAuditVo vo) {
        return userCashRecordMapper.userCashCheckQuery(vo);
    }

    public Integer updateStatus(Integer cashId) {
        return userCashRecordMapper.updateStatus(cashId);
    }

    public int updateStatusAndNayReason(Integer cashId, String nayReason) {
        return userCashRecordMapper.updateStatusAndNayReason(cashId,nayReason);
    }

    public List<PartnersInviteVo> partnersInviteQuery(PartnersInviteVo vo) {
        return partnersInviteMapper.partnersInviteQuery(vo);
    }

    public List<RecyclersVo> recyclersQuery(RecyclersVo vo) {
        return partnersInviteMapper.recyclersQuery(vo);
    }

    public Integer addRecyclers(RecyclersVo vo) {
        return partnersInviteMapper.addRecyclers(vo);
    }

    public List<RecyclersVo> selectRecyclersByRecyclersId(String recyclersid) {
        return recyclersMapper.selectRecyclersByRecyclersId(recyclersid);
    }









    //银行卡提现审核分页查询
    public List<ManagerAndRecordVo> selectFen(ManagerAndRecordVo managerAndRecordVo){


        return sysManagerMapper.selectFen(managerAndRecordVo);
    }
    //合伙人提现审核分页查询
    public List<PartnersAndRecordVo> selectFen2(PartnersAndRecordVo partnersAndRecordVo){
        return partnersMapper.selectFen(partnersAndRecordVo);
    }

    //审核通过
    public Integer updateStatus1(Integer cashId){
        return sysManagerMapper.updateStatus(cashId);
    }

    //驳回操作
    public int updateStatusAndNayReason1(Integer cashId,String nayReason){
        return sysManagerMapper.updateStatusAndNayReason(cashId,nayReason);
    }

    //运维管理补货记录
    public List<GoodsAndReplenishmentVo> selectBuHuo(GoodsAndReplenishmentVo goodsAndReplenishmentVo){
        return replenishmentRecordMapper.selectBuHuo(goodsAndReplenishmentVo);
    }

    //运维故障处理记录
    public List<FaultAndReplenishmentVo> selectFault(FaultAndReplenishmentVo faultAndReplenishmentVo){
        return deviceFaultRecordMapper.selectFault(faultAndReplenishmentVo);
    }

    //场地管理列表
    public List<VenuesVo> selectVenues(VenuesVo venuesVo){
        return venuesMapper.selectVenues(venuesVo);
    }
    //场地管理新增场地
    public int AddVenues(Venues venues){
        String changeaddress = venues.getChangeaddress();
        //拆分过后给她赋值
        String[] array =changeaddress.split("/");
        venues.setProvince(array[0]);
        venues.setCity(array[1]);
        venues.setArea(array[2]);
        return venuesMapper.insertSelective(venues);
    }


    /**
     * 秦梗北
     * @param venues
     * @return
     */


    //场地管理删除
    public int DelVenues(Venues venues){
        return venuesMapper.DelVenues(venues);
    }
    //场地管理修改
    public int UpdateVenues(Venues venues){
        return venuesMapper.updateByPrimaryKeySelective(venues);
    }

    //搜索场地ID来修改
    public Venues selectVenuedId(String venuesid) {
        return venuesMapper.selectVenuedId(venuesid);
    }

    //邀请列表
    public int selectUser(UserInviterVo userInviterVo) {
        return userInviteMapper.selectUser(userInviterVo);
    }

    public List<UserInviterVo> selectCount(UserInviterVo userInviterVo, int pageNum, int pageSize) {
        pageNum=pageNum==0 ? 1 :pageNum;
        pageSize=pageSize==0 ? 5 :pageSize;
        return userInviteMapper.selectCount(userInviterVo,(pageNum-1)*pageSize,pageSize);
    }

    public List<SysManagerVo> selectBySorting(SysManagerVo sysManagerVo, int pageNum, int pageSize) {
        pageNum=pageNum==0 ? 1 :pageNum;
        pageSize=pageSize==0 ? 5 :pageSize;
        return sysManagerMapper.selectBySorting(sysManagerVo,(pageNum-1)*pageSize,pageSize);
    }

    public int selectBySortingCount(SysManagerVo sysManagerVo) {
        return sysManagerMapper.selectBySortingCount(sysManagerVo);
    }

    // 查出减的积分
    public List<SysManagerVo> selectBySortingNum() {
        return sysManagerMapper.selectBySortingNum();
    }

    //搜索分连中心ID来修改
    public SysManager selectByManagerId(String managerId) {
        return sysManagerMapper.selectByPrimaryKey(managerId);
    }

    //添加分练中心
    public int addBySorting(SysManager sysManager) {
        return sysManagerMapper.insertSelective(sysManager);
    }

    //修改分练中心
    public int updateBySorting(SysManager sysManager) {
        return sysManagerMapper.updateByPrimaryKeySelective(sysManager);
    }

    //删除分练中心
    public int delBySorting(String managerId) {
        return sysManagerMapper.deleteByPrimaryKey(managerId);
    }

}
